package com.facebook.imagepipeline.platform;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.os.MemoryFile;
import com.facebook.common.internal.Preconditions;
import com.facebook.common.internal.Throwables;
import com.facebook.common.references.CloseableReference;
import com.facebook.common.webp.WebpBitmapFactory;
import com.facebook.common.webp.WebpSupportStatus;
import com.facebook.imagepipeline.memory.PooledByteBuffer;
import java.io.FileDescriptor;
import java.io.IOException;
import java.lang.reflect.Method;

public class GingerbreadPurgeableDecoder extends DalvikPurgeableDecoder
{
  private static Method sGetFileDescriptorMethod;
  private final boolean mWebpSupportEnabled;

  public GingerbreadPurgeableDecoder(boolean paramBoolean)
  {
    this.mWebpSupportEnabled = paramBoolean;
  }

  // ERROR //
  private static MemoryFile copyToMemoryFile(CloseableReference<PooledByteBuffer> paramCloseableReference, int paramInt, @javax.annotation.Nullable byte[] paramArrayOfByte)
    throws IOException
  {
    // Byte code:
    //   0: aload_2
    //   1: ifnonnull +114 -> 115
    //   4: iconst_0
    //   5: istore_3
    //   6: new 22	android/os/MemoryFile
    //   9: dup
    //   10: aconst_null
    //   11: iload_1
    //   12: iload_3
    //   13: iadd
    //   14: invokespecial 25	android/os/MemoryFile:<init>	(Ljava/lang/String;I)V
    //   17: astore 4
    //   19: aload 4
    //   21: iconst_0
    //   22: invokevirtual 29	android/os/MemoryFile:allowPurging	(Z)Z
    //   25: pop
    //   26: aconst_null
    //   27: astore 6
    //   29: aconst_null
    //   30: astore 7
    //   32: aconst_null
    //   33: astore 8
    //   35: new 31	com/facebook/imagepipeline/memory/PooledByteBufferInputStream
    //   38: dup
    //   39: aload_0
    //   40: invokevirtual 37	com/facebook/common/references/CloseableReference:get	()Ljava/lang/Object;
    //   43: checkcast 39	com/facebook/imagepipeline/memory/PooledByteBuffer
    //   46: invokespecial 42	com/facebook/imagepipeline/memory/PooledByteBufferInputStream:<init>	(Lcom/facebook/imagepipeline/memory/PooledByteBuffer;)V
    //   49: astore 9
    //   51: new 44	com/facebook/common/streams/LimitedInputStream
    //   54: dup
    //   55: aload 9
    //   57: iload_1
    //   58: invokespecial 47	com/facebook/common/streams/LimitedInputStream:<init>	(Ljava/io/InputStream;I)V
    //   61: astore 10
    //   63: aload 4
    //   65: invokevirtual 51	android/os/MemoryFile:getOutputStream	()Ljava/io/OutputStream;
    //   68: astore 8
    //   70: aload 10
    //   72: aload 8
    //   74: invokestatic 57	com/facebook/common/internal/ByteStreams:copy	(Ljava/io/InputStream;Ljava/io/OutputStream;)J
    //   77: pop2
    //   78: aload_2
    //   79: ifnull +13 -> 92
    //   82: aload 4
    //   84: aload_2
    //   85: iconst_0
    //   86: iload_1
    //   87: aload_2
    //   88: arraylength
    //   89: invokevirtual 61	android/os/MemoryFile:writeBytes	([BIII)V
    //   92: aload_0
    //   93: invokestatic 65	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
    //   96: aload 9
    //   98: invokestatic 71	com/facebook/common/internal/Closeables:closeQuietly	(Ljava/io/InputStream;)V
    //   101: aload 10
    //   103: invokestatic 71	com/facebook/common/internal/Closeables:closeQuietly	(Ljava/io/InputStream;)V
    //   106: aload 8
    //   108: iconst_1
    //   109: invokestatic 75	com/facebook/common/internal/Closeables:close	(Ljava/io/Closeable;Z)V
    //   112: aload 4
    //   114: areturn
    //   115: aload_2
    //   116: arraylength
    //   117: istore_3
    //   118: goto -112 -> 6
    //   121: astore 11
    //   123: aload_0
    //   124: invokestatic 65	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
    //   127: aload 6
    //   129: invokestatic 71	com/facebook/common/internal/Closeables:closeQuietly	(Ljava/io/InputStream;)V
    //   132: aload 7
    //   134: invokestatic 71	com/facebook/common/internal/Closeables:closeQuietly	(Ljava/io/InputStream;)V
    //   137: aload 8
    //   139: iconst_1
    //   140: invokestatic 75	com/facebook/common/internal/Closeables:close	(Ljava/io/Closeable;Z)V
    //   143: aload 11
    //   145: athrow
    //   146: astore 11
    //   148: aload 9
    //   150: astore 6
    //   152: aconst_null
    //   153: astore 7
    //   155: aconst_null
    //   156: astore 8
    //   158: goto -35 -> 123
    //   161: astore 11
    //   163: aload 10
    //   165: astore 7
    //   167: aload 9
    //   169: astore 6
    //   171: goto -48 -> 123
    //
    // Exception table:
    //   from	to	target	type
    //   35	51	121	finally
    //   51	63	146	finally
    //   63	78	161	finally
    //   82	92	161	finally
  }

  private Method getFileDescriptorMethod()
  {
    try
    {
      Method localMethod1 = sGetFileDescriptorMethod;
      if (localMethod1 == null);
      try
      {
        sGetFileDescriptorMethod = MemoryFile.class.getDeclaredMethod("getFileDescriptor", new Class[0]);
        Method localMethod2 = sGetFileDescriptorMethod;
        return localMethod2;
      }
      catch (Exception localException)
      {
        throw Throwables.propagate(localException);
      }
    }
    finally
    {
    }
  }

  private FileDescriptor getMemoryFileDescriptor(MemoryFile paramMemoryFile)
  {
    try
    {
      FileDescriptor localFileDescriptor = (FileDescriptor)getFileDescriptorMethod().invoke(paramMemoryFile, new Object[0]);
      return localFileDescriptor;
    }
    catch (Exception localException)
    {
      throw Throwables.propagate(localException);
    }
  }

  protected Bitmap decodeByteArrayAsPurgeable(CloseableReference<PooledByteBuffer> paramCloseableReference, BitmapFactory.Options paramOptions)
  {
    return decodeFileDescriptorAsPurgeable(paramCloseableReference, ((PooledByteBuffer)paramCloseableReference.get()).size(), null, paramOptions);
  }

  protected Bitmap decodeFileDescriptorAsPurgeable(CloseableReference<PooledByteBuffer> paramCloseableReference, int paramInt, byte[] paramArrayOfByte, BitmapFactory.Options paramOptions)
  {
    MemoryFile localMemoryFile = null;
    try
    {
      localMemoryFile = copyToMemoryFile(paramCloseableReference, paramInt, paramArrayOfByte);
      FileDescriptor localFileDescriptor = getMemoryFileDescriptor(localMemoryFile);
      if (this.mWebpSupportEnabled);
      Bitmap localBitmap1;
      for (Object localObject2 = WebpSupportStatus.sWebpBitmapFactory.decodeFileDescriptor(localFileDescriptor, null, paramOptions); ; localObject2 = localBitmap1)
      {
        Bitmap localBitmap2 = (Bitmap)Preconditions.checkNotNull(localObject2, "BitmapFactory returned null");
        return localBitmap2;
        localBitmap1 = BitmapFactory.decodeFileDescriptor(localFileDescriptor, null, paramOptions);
      }
    }
    catch (IOException localIOException)
    {
      throw Throwables.propagate(localIOException);
    }
    finally
    {
      if (localMemoryFile != null)
        localMemoryFile.close();
    }
  }

  protected Bitmap decodeJPEGByteArrayAsPurgeable(CloseableReference<PooledByteBuffer> paramCloseableReference, int paramInt, BitmapFactory.Options paramOptions)
  {
    if (endsWithEOI(paramCloseableReference, paramInt));
    for (byte[] arrayOfByte = null; ; arrayOfByte = EOI)
      return decodeFileDescriptorAsPurgeable(paramCloseableReference, paramInt, arrayOfByte, paramOptions);
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.facebook.imagepipeline.platform.GingerbreadPurgeableDecoder
 * JD-Core Version:    0.6.2
 */